
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<!DOCTYPE html>
<html style="width: 100%;overflow-x: auto;position:relative ">
<head>
    <title>管理已发布的考核任务</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="stylesheet" href="/css/officialDocument/officialDocument.css">

    <link rel="stylesheet" href="/lib/layer/skin/default/layer.css">
    <link type="text/css" rel="stylesheet" href="/lib/pagination/style/pagination.css">
    <link rel="stylesheet" href="/css/base/base.css?20201106.1">

    <script src="/js/common/language.js"></script>

    <script type="text/javascript" src="/js/jquery/jquery-1.9.1.js"></script>
    <script src="/js/jquery/jquery.cookie.js"></script>
    <script type="text/javascript" src="/js/base/tablePage.js"></script>
    <script src="/lib/layer/layer.js?20201106"></script>
    <script src="/js/base/base.js"></script>
    <script src="/lib/laydate/laydate.js"></script>
    <script type="text/javascript" charset="utf-8" src="/lib/pagination/js/jquery.pagination.min.js"></script>

<%--<script src="/js/document/makeADraft.js"></script>--%>
    <link rel="stylesheet" type="text/css" href="/css/commonTheme/${sessionScope.InterfaceModel}/commonTheme.css"/>
    <style>

        table tr {
            border-width: 1px;
            border-style: solid;
            border-color: rgb(204, 204, 204);
            border-image: initial;
        }
        table tr th {
            font-size: 13pt;
            color: rgb(47, 92, 143);
            text-align: center;
            padding: 6px;
        }

        table  td {
            font-size: 11pt;
            padding: 6px;
            height: 30px;
            line-height: 30px;
            text-align: center;
            word-break: keep-all;
            white-space: nowrap;
            text-overflow: ellipsis;
            overflow: hidden;
        }
        table tr:nth-child(2n) {
            background-color: rgb(255, 255, 255);
        }
        table tr:nth-child(2n+1) {
            background-color:#F6F7F9 ;
        }
        .newLeave {
            border-radius: 3px;
            margin-right: 3%;
            float: right;
            width: 70px;
            height: 28px;
            color: #fff;
            font-size: 14px;
            line-height: 28px;
            margin-right: 3%;
            margin-top: 14px;
            cursor: pointer;
            background: #2b7fe0
        }
        .clearfix {
            margin: 5px auto;
            width: 93%;
        }
        textarea.BigStatic {
            font-size: 10pt;
            padding: 1px 5px;
            border: 1px solid #C0BBB4;
            background: #E0E0E0;
            height: 26px;
            border-radius:5px;
            width: 125px;
            /*margin-left: 32px;*/
        }
        .index-desc{
            height: 95px;
            float: left;
            line-height: 95px;
            margin-right: 9px;
        }
        .lab-set{
            height: 50px;
            float: left;
            line-height: 47px;

        }
        #portalName{
            height: 30px;
            margin-right: 16px;
        }
        .li-set p{
            margin: 5px 0 0 103px;
        }
        .M-box3 .active {
            margin: 0px 3px;
            width: 38px;
            height: 38px;
            line-height: 38px;
            background: #2b7fe0;
            font-size: 12px;
            border: 1px solid #2b7fe0;
            color: #fff;
            text-align: center;
            display: inline-block;
        }
        .M-box3 {
            margin-top: 30px;
            position: fixed;
            bottom: 10px;
            right: 76px;
            text-align: center;
        }
        .M-box3 a {
            margin: 0 3px;
            width: 38px;
            height: 38px;
            line-height: 38px;
            font-size: 12px;
            display: inline-block;
            text-align: center;
            background: #fff;
            border: 1px solid #ebebeb;
            color: #333;
            text-decoration: none;
        }
        .jump-ipt {
            width: 38px;
            height: 38px;
            line-height: 38px;
            text-align: center;
            padding: 0;
        }
        .main{
            margin-top: 40px;
            margin-left: 44px;
            height:60px;
        }
        .main ul{
            height:40px;
            margin-top: 5px;
        }
        .main li{
            margin-right: 4%;
            float: left;
        }
        .main .leftspan{
            vertical-align: middle;
        }
        .main a{
            margin: 2px;
            color: #007cfd;
            position: relative;
            top:-12px;
        }
        #kaoheBiaoji{
            margin-left: 12px;
        }
        select {
            margin-left: 12px;
            width: 139px;
            height: 30px;
            border: 1px solid #ccc;
            border-radius: 4px;
            padding-left: 6px;
        }
        .del{
            color: #e01919;
        }
        .main .orgClear{
            color: #e01919;
        }
        #newMain  .leftspan{
            display: inline-block;
            width: 156px;
            text-align: right;
            margin-right: 52px;
            vertical-align: top;
        }
        #newMain input{
            width: 250px;
            height: 30px;
            border: 1px solid #ccc;
            border-radius: 2px;
            padding-left: 6px;
        }
        #newMain li{
            list-style: none;
            margin:12px 0;
            padding: 0;
        }
        #newMain .inputsmall{
            width: 116px;
            height: 30px;
            text-align: center;
            padding-left: 0px;
        }
        #newMain select {
            width: 258px;
            height: 30px;
            border: 1px solid #ccc;
            border-radius: 2px;
            padding-left: 6px;
            margin-left: 0;
        }
        #newMain .mustinput{
            color: red;
            height: 26px;
            line-height: 32px;
            margin-left: 5px;
        }
        #newMain .btn{
            color: #2e8ded;
        }
        #newMain .clear{
            color: #e01919;
        }
        #newMain .clear3{
            color: #e01919;
        }
        #newMain .clear4{
            color: #e01919;
        }
        #newMain .adddept:hover{
              cursor:pointer;
        }
        #newMain .clear:hover{
            cursor:pointer;
        }
        .head-top {
            width: 100%;
            position: fixed;
            top: 0px;
            left: 0px;
            height: 45px;
            border-bottom: 1px solid #999;
            background: #fff;
            overflow: hidden;
            z-index: 9999999;
        }
        .head-top ul .head-top-li {
            height: 26px;
            line-height: 26px;
            margin: 6px 11px 0px 11px;
            padding: 1px 20px;
            font-size: 14px;
            border-radius: 20px;
            cursor: pointer;
        }
        .navigation {
            width: 100%;
            box-sizing: border-box;
            height: 70px;
            padding-left: 34px;
            line-height: 70px;
        }
        .navigation img {
            vertical-align: middle;
        }
        .navigation h2 {
            font-weight: normal;
            display: inline-block;
            font-size: 22px;
            color: #494d59;
            vertical-align: middle;
            margin-left: 10px;
        }
        .newClass{
            float: right;
            width: 90px;
            height: 28px;
            background: url(../../img/file/cabinet01.png) no-repeat;
            color: #fff;
            font-size: 14px;
            line-height: 28px;
            margin: 2%  3% 0 0;
            cursor: pointer;
        }
    </style>
</head>
<body>
<div class="navigation">
    <img src="/img/kaoheguanli.png" alt="">
    <h2>考核任务管理</h2>
    <div class="newClass" id="newClass">
            <span style="margin-left: 30px;">
                <img style="margin-right: 4px;margin-left: -11px;margin-bottom: 2px;" src="../../img/mywork/newbuildworjk.png" alt="">
                新建
            </span>
    </div>
</div>
        <table style="margin:4px auto;width:95%" >
    <thead>
        <tr style="background: none">
            <th style="width:12%">考核任务名称	</th>
            <%--<th>考核人</th>--%>
            <th>被考核人</th>
            <th style="width:12%">考核试卷</th>
            <th style="width:12%">生效日期</th>
            <th style="width:12%">终止日期	</th>
            <th>状态</th>
            <th>未考核人员</th>
            <th style="width: 25%">操作</th>
        </tr>
    </thead>
    <tbody id="taskBody">

    </tbody>
</table>
<div id="dbgz_page" class="M-box3">

</div>

<script>
    //列表带分页
    function undefindData(data) {
        if(data == undefined){
            return '';
        }else{
            return data;
        }
    }
    var ajaxPageTr={
        data:{
            page:1,//当前处于第几页
            pageSize:5,//一页显示几条
            useFlag:true
            // computationNumber:null
        },
        page:function () {
            var me=this;
            layer.msg('加载中', {
                icon: 16
                ,shade: 0.01
            });
            $.ajax({
                type:'post',
                url:'/ScoreFlowLeader/selAllScoreFlow',
                dataType:'json',
                data:me.data,
                success:function(res){
                    if(res.flag==true){
                        var str='';
                        $.each(res.obj, function (index, item) {
                            var opt ='';
                            if(item.flowFlag=='1'||item.flowFlag=='2'){
                                opt = '<a class="bianji" href="javascript:;"  style="margin-right: 10px">修改</a>' +
                                    '<a class="del" href="javascript:;"  style="margin-right: 10px">删除</a>';
                            }
                            if(item.flowFlag=='0'){
                                opt += '<a class="zhongzhi" href="javascript:;"  style="margin-right: 10px">立即终止</a>'
                            }else if(item.flowFlag=='1'){
                                opt += '<a class="zhongzhi" href="javascript:;"  style="margin-right: 10px">发起考核</a>'
                            }else if(item.flowFlag=='2'){
                                opt += '<a class="zhongzhi" href="javascript:;"  style="margin-right: 10px">恢复生效</a>'
                            }

                            str += '<tr groupId="'+item.groupId+'" flowId="'+item.flowId+'" flowFlag="'+item.flowFlag+'" rankman="'+item.rankman+'"  participant="'+item.participant+'">' +
                                '<td title="'+undefindData(item.flowTitle) +'">' + undefindData(item.flowTitle) + '</td>' +
                                // '<td title="'+undefindData(item.rankmanName)+'"><a href="javascript:;" class="kaoherankman">'+ undefindData(item.rankmanName)+ '</a></td>' +
                                '<td title="'+undefindData(item.participantName) +'"><a href="javascript:;" class="kaoheparticipant">' + undefindData(item.participantName) + '</a></td>' +
                                '<td title="'+undefindData(item.groupName)+'"><a href="javascript:;" class="kaohegroupName">' + undefindData(item.groupName)+ '</a></td>' +
                                '<td title="'+undefindData(item.beginDateStr)+'">' + undefindData(item.beginDateStr)+ '</td>' +
                                '<td title="'+undefindData(item.endDateStr)+'">' + undefindData(item.endDateStr)+ '</td>' +
                                '<td>' + function () {
                                    if(item.flowFlag=='0' ){
                                        return '<span style="color:#00AA00">考核中</span>'
                                    }else if(item.flowFlag=='1' ){
                                        return '<span style="color:red">未考核</span>'
                                    }else if(item.flowFlag=='2' ){
                                        return '<span style="color:red">终止</span>'
                                    }else if(item.flowFlag=='3' ){
                                        return '<span style="color:#00AA00">考核结束</span>'
                                    }
                                }()+ '</td>' +
                                '<td id="assessor_'+index+'" class="assessor_name">'+(item.assessorName || '')+'</td>' +
                                '<td>' +
                                '<a class="clone" href="javascript:;"  style="margin-right: 10px">克隆</a>' +
                                    opt +
                                '<a class="showpeo" href="javascript:;"  style="margin-right: 10px">显示人员</a>' +
                                '</td>' +
                                '</tr>';
                        })
                        $('#taskBody').html(str);
                        $('.assessor_name').hover(function(){
                            var id = $(this).attr('id');
                            var text = $(this).text();
                            if (text) {
                                layer.tips(text.replace(/,$/, ''), '#'+id);
                            }
                        });
                        layer.closeAll();
                        me.pageTwo(res.totleNum,me.data.pageSize,me.data.page)
                    }else{
                        layer.msg("暂无数据", {icon: 2})
                    }

                }
            })

        },
        pageTwo:function (totalData, pageSize,indexs) {
            var mes=this;
            $('#dbgz_page').pagination({
                totalData: totalData,
                showData: pageSize,
                prevContent:'上一页',
                nextContent:'下一页',
                jump: true,
                coping: true,
                homePage:'',
                endPage: '',
                current:indexs||1,
                callback: function (index) {
                    mes.data.page=index.getCurrent();
                    mes.page();
                }
            });
        }
    }
    ajaxPageTr.page();
    //        新建
    $(document).on('click','.newClass',function () {
        $(window.parent.document).find('.main').find('iframe').prop('src','/ScoreFlowLeader/assessmentNewedit')
    })
    //编辑
    $(document).on('click','.bianji',function () {
        var flowId=$(this).parent().parent().attr('flowId')
        $(window.parent.document).find('.main').find('iframe').prop('src','/ScoreFlowLeader/assessmentNewedit?type=0&&flowId='+flowId)
    })
    //删除
    $('table').on('click','.del',function(){
        var flowId=$(this).parent().parent().attr('flowId')
        layer.open({
            type: 1,
            title: ['提示','background-color:#2e8ded;color:#fff'],
            content:'<div style="text-align: center;margin-top: 18px;">确认删除吗？</div>',
            area: ['200px', '160px'],
            btn: ['确认','取消'],
            yes:function(index){
                $.ajax({
                    url:'/ScoreFlowLeader/delScoreFlow',
                    type:'post',
                    data:{
                        'flowId':flowId,
                    },
                    dataType:'json',

                    success:function(res){
                        layer.close(index)
                        if(res){
                            layer.msg("删除成功",{
                                icon: 1,
                                time: 1500 //2秒关闭（如果不配置，默认是3秒）
                            },function(){
                                location.href="/ScoreFlowLeader/assessmentTaskment "
                            })
                        }else {
                            layer.msg("删除失败",{
                                icon: 2,
                                time: 1500 //2秒关闭（如果不配置，默认是3秒）
                            },function(){
                                location.href="/ScoreFlowLeader/assessmentTaskment"
                            })
                        }
                    }
                })
            },
            btn2: function (index) {
                layer.close(index)
            }

        })
    });
    //考核情况
    // $('table').on('click','.kaohe',function(){
    //     var flowId=$(this).parent().parent().attr('flowId')
    //     var participant=$(this).parent().parent().attr('participant')
    //     layer.open({
    //         title: ['考核情况', 'background-color:#2b7fe0;color:#fff;'],
    //         area: ['500px', '350px'],
    //         shadeClose: false, //点击遮罩关闭
    //         content: ' <table><thead><tr><th>考核人员</th><th>已考核人员</th><th>未考核人员</th></tr></thead><tbody id="bodywarp"></tbody></table>',
    //         btn: ['取消'],
    //         success:function(){
    //             $.ajax({
    //                 type:'get',
    //                 url:'/ScoreSelfDataController/getKaohe',
    //                 dataType:'json',
    //                 data:{
    //                     flowId:flowId,
    //                     examiner:participant
    //                 },
    //                 success:function(res){
    //                     var str='';
    //                     var item = res.obj;
    //                     str += '<tr>' +
    //                         '<td>' +undefindData(item[0]) + '</td>' +
    //                         '<td>' + undefindData(item[1])+ '</td>' +
    //                         '<td>' + undefindData(item[2])+ '</td>' +
    //                         '</tr>';
    //
    //
    //                     $('#bodywarp').html(str)
    //                 }
    //             });
    //         },
    //         yes:function(index){
    //             layer.close(index);
    //         }
    //     })
    // });
    //考核试卷
    $('table').on('click','.kaohegroupName',function(){
        var groupId=$(this).parent().parent().attr('groupId')
        layer.open({
            title: ['考核情况', 'background-color:#2b7fe0;color:#fff;'],
            area: ['500px', '350px'],
            shadeClose: false, //点击遮罩关闭
            content: ' <table><thead><tr><th>考核项目</th><th>分值范围</th><th>描述</th></tr></thead><tbody id="bodywarp"></tbody></table>',
            btn: ['取消'],
            success:function(){
                $.ajax({
                    type:'get',
                    url:'/ScoreItemLeader/selScoreItem',
                    dataType:'json',
                    data:{
                        groupId:groupId
                    },
                    success:function(res){
                        var str='';
                        $.each(res.obj, function (index, item) {
                            str += '<tr groupId="'+item.groupId+'" flowId="'+item.flowId+'" flowFlag="'+item.flowFlag+'">' +
                                '<td title="'+item.itemName+'">' + undefindData(item.itemName)+ '</td>' +
                                '<td>' +undefindData(item.min)  +' ~ '+undefindData(item.max)+ '</td>' +
                                '<td title="'+item.itemExplain +'">' + undefindData(item.itemExplain) + '</td>' +
                                '</tr>';

                        })
                        $('#bodywarp').html(str)
                    }
                });
            },
            yes:function(index){
                layer.close(index);
            }
        })
    });

    //查是否有权限使用提醒
    var htmlStr = '';
    var remindUseFlag = false;
    $.ajax({
        type:'get',
        url:'/smsRemind/getRemindFlag',
        dataType:'json',
        data:{
            type:15
        },
        success:function (res) {
            if(res.flag){
                if(res.obj.length>0){
                    var data = res.obj[0];
                    htmlStr = '<div class="remind_div" style="margin-top: 40px; padding-left: 85px;">';
                    // 是否默认发送
                    if(data.isRemind=='0'){
                        htmlStr+='<input id="remind" type="checkbox" name="remind"  class="remindCheck" >\n';
                    }else if(data.isRemind=='1'){
                        htmlStr+='<input id="remind" type="checkbox" name="remind"  class="remindCheck" checked >\n';
                    }
                    htmlStr+= '<label for="remind" class="remind_msg" style="margin-right: 20px;">发送事务提醒</label>';
                    // 是否手机短信默认提醒
                    if(data.isIphone=='0'){
                        htmlStr+='<input id="smsDefault" type="checkbox" name="smsDefault" class="smsDefault">'
                    } else if (data.isIphone=='1'){
                        htmlStr+='<input id="smsDefault" type="checkbox" name="smsDefault" class="smsDefault" checked>'
                    }
                    htmlStr+= '<label for="smsDefault" class="remind_msg">使用手机短信提醒</label></div>';
                    // 是否允许发送事务提醒
                    if(data.isCan=='1'){
                        remindUseFlag = true;
                    }

                }
            }
        }
    })
    //考核终止
    $('table').on('click','.zhongzhi',function(){
        var data ={};
        var flowFlag=$(this).parent().parent().attr('flowFlag')
        data.flowId=$(this).parent().parent().attr('flowId')
        data.remindVal = 0;
        data.smsDefault = 0;
        if(flowFlag==2||flowFlag==1){
            data.flowFlag=0
            if(remindUseFlag){
                layer.open({
                    type: 1,
                    skin: 'layui-layer-rim', //加上边框
                    area: ['420px', '200px'], //宽高
                    content: htmlStr,
                    title:"是否发送事务提醒？",
                    btn: ['确定','取消'],
                    yes: function(index, layero){
                        if($('.remindCheck').is(":checked")){
                            data.remindVal=1;
                        }
                        if($('.smsDefault').is(":checked")){
                            data.smsDefault=1;
                        }
                        stopNow(data);
                    },
                    btn2:function(index, layero){
                        layer.closeAll();
                        stopNow(data);
                    },
                });
            }
        }else{
            data.flowFlag=2;
            stopNow(data);
        }
    });
    function stopNow(data){
        $.ajax({
            url:'/ScoreFlowLeader/stopNow',
            type:'post',
            data:{
                flowId:data.flowId,
                flowFlag:data.flowFlag,
                remind:data.remindVal,
                tuisong:data.smsDefault
                /* beginDateStr:myDate*/
            },
            dataType:'json',
            success:function(res){
                location.href = "/ScoreFlowLeader/assessmentTaskment"
            }
        })
    }
    //克隆
    $('table').on('click','.clone',function(){
        var flowId=$(this).parent().parent().attr('flowId')
        $.ajax({
            url:'/ScoreFlowLeader/kelong',
            type:'post',
            data:{
                flowId:flowId
            },
            dataType:'json',
            success:function(res){
                layer.msg("克隆成功", {
                    icon: 1,
                    time: 1500 //2秒关闭（如果不配置，默认是3秒）
                }, function () {
                    location.href = "/ScoreFlowLeader/assessmentTaskment"
                });
            }
        })
    });
    //显示人员
    $('table').on('click','.showpeo',function(){
        var flowId=$(this).parent().parent().attr('flowId');
        var flowFlag = $(this).parent().parent().attr('flowFlag');
        location.href='/scoreFlowUserLeader/userList?flowId='+flowId+'&flowFlag='+flowFlag;
    });
</script>
</body>
</html>
